package game;

import java.util.HashSet;
import java.util.Set;

public class Game {
    public static void checkSpecialNoParam(int[] specialNo) {
        if (specialNo.length < 3) {
            throw new RuntimeException("不是3个数");
        }
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < specialNo.length; i++) {
            if (specialNo[i] < 1 || specialNo[i] > 9) {
                throw new RuntimeException("不是个位数");
            }
            set.add(specialNo[i]);
        }
        if (set.size() < 3) {
            throw new RuntimeException("不能相同");
        }
    }

    public static String checkOneNumIsSpecialNumMultipleThenShouldReturnTheRelevantWord(int[] specialNo, int num) {
        if (num % specialNo[0] == 0) {
            return "端";
        }
        if (num % specialNo[1] == 0) {
            return "午";
        }
        if (num % specialNo[2] == 0) {
            return "节";
        }
        return "";
    }

    public static String checkOneNumIsMoreThanTwoSpecialNumMultipleThenShouldReturnTheRelevantWord(int[] specialNo, int num) {
        if (num % (specialNo[0] * specialNo[1] * specialNo[2]) == 0) {
            return "端午节";
        }
        if (num % (specialNo[0] * specialNo[1]) == 0) {
            return "端午";
        }
        if (num % (specialNo[1] * specialNo[2]) == 0) {
            return "午节";
        }
        if (num % (specialNo[0] * specialNo[2]) == 0) {
            return "端节";
        }
        return "";
    }

    public static String checkOneNumIsContainsFirstSpecialNumThenShouldReturnTheRelevantWord(int[] specialNo, int num) {
        if (String.valueOf(num).contains(String.valueOf(specialNo[0]))) {
            return "端";
        }
        return "";
    }

    public static String checkInput1ToMoreSizeThenShouldReturnTheRelevantWord(int[] specialNo, int size) {
        checkSpecialNoParam(specialNo);

        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= size; i++) {
            if (!"".equals(checkOneNumIsContainsFirstSpecialNumThenShouldReturnTheRelevantWord(specialNo, i))) {
                sb.append(checkOneNumIsContainsFirstSpecialNumThenShouldReturnTheRelevantWord(specialNo, i)).append(",");
            } else if (!"".equals(checkOneNumIsMoreThanTwoSpecialNumMultipleThenShouldReturnTheRelevantWord(specialNo, i))) {
                sb.append(checkOneNumIsMoreThanTwoSpecialNumMultipleThenShouldReturnTheRelevantWord(specialNo, i)).append(",");
            } else if (!"".equals(checkOneNumIsSpecialNumMultipleThenShouldReturnTheRelevantWord(specialNo, i))) {
                sb.append(checkOneNumIsSpecialNumMultipleThenShouldReturnTheRelevantWord(specialNo, i)).append(",");
            } else {
                sb.append(i).append(",");
            }
        }

        return sb.toString().substring(0, sb.toString().length() - 1);
    }

    public static void main(String[] args) {
        int[] specialNo = {3, 5, 7};
        checkSpecialNoParam(specialNo);
        System.out.println(checkInput1ToMoreSizeThenShouldReturnTheRelevantWord(specialNo, 100));

    }

}
